<?php

namespace app\index\controller;

use EasyWeChat\Kernel\Messages\News;
use EasyWeChat\Work\GroupRobot\Messages\Markdown;
use app\common\controller\Frontend;
use EasyWeChat\Factory;
use app\admin\model\Assistant as AssistantModel;
use EasyWeChat\Work\GroupRobot\Messages\NewsItem;
use EasyWeChat\Work\GroupRobot\Messages\Text;
use EasyWeChatComposer\EasyWeChat;
use fast\Http;

class Assistant extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
    protected $apps;

    public function _initialize()
    {
        $this->apps = Factory::work(AssistantModel::config());
        parent::_initialize();
    }

    /**
     * 创建群聊
     * @return string
     * @throws \EasyWeChat\Kernel\Exceptions\HttpException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \Psr\SimpleCache\InvalidArgumentException
     * @throws \think\Exception
     */
    public function index()
    {
        $app = Factory::work(AssistantModel::config());
        $token = $app->access_token->getToken();//获取企业微信token
        $url = "https://qyapi.weixin.qq.com/cgi-bin/appchat/create?access_token={$token['access_token']}";
        $params = [
            'name'=>'老师领取-通知群',
            'owner'=>'GaoZhenYu',
            'userlist'=>['GaoZhenYu','SunDan','ZhangWei','WuJinJun']
        ];
        //参数以json格式传送
        $response = \fast\Http::post($url,json_encode($params));
        //{"errcode":0,"errmsg":"ok","chatid":"14461621356868135921"} 样书预约-通知群
        //{"errcode":0,"errmsg":"ok","chatid":"14186620304621825010"} 报名表-通知群
        //{"errcode": 0,"errmsg": "ok","chatid":"9607303908516162894"} 提分超市支付通知群
        //{"errcode": 0,"errmsg": "ok","chatid":"16703006596415092261"} //考前突破卷·数学-通知群
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAArUogbYnKOf70o-F7tHQaXg"} //招募令通知群
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAAHwIu_oKVuTuRH0XQDTEchw"} //小学赠品《全知识点普查彩图试卷》纸质版领取
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAAm2NolRU_W4XoV0nhKvBiOg"} //小学教师赠品《小学生绘本课堂·教案》纸质版领取
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAA05Ae05n9Eo-o68viQabrsQ"} //考前突破卷数学
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAAGv3aPuqHPVh1pzRWYFV--A"} //退货通知群
        //{"errcode": 0,"errmsg": "ok","chatid":"wrhInZCgAAoC8lFBSYvvXVjp2Cr1JWXw"} //考前猜题卷领取
        //{errcode: 0,errmsg: "ok",chatid: "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g"}  财务审核 物流  通知
        //{errcode: 0,errmsg: "ok",chatid: "677f24e7-f84d-44a0-8e65-6ebe8ee38204"}  财务审核 物流  通知
        //{errcode: 0,errmsg: "ok",chatid: "wrhInZCgAAG8n7tVlN7TYnV3vkAkrZmg"}   OA报错提醒-通知群
        //{"errcode": 0,"errmsg": "ok", "chatid": "wrhInZCgAAmd73Q1zqFF3Fh-mqNGbHLA"} 高考一轮复习-通知群
        //{ "errcode": 0,"errmsg": "ok","chatid": "wrhInZCgAAGdxg6PkNtTlzuzQ2EeMmkw"} 新提分超市订单-通知群
        //{"errcode": 0,"errmsg": "ok","chatid": "wrhInZCgAA3jsm8OBPP3HOhBhuRTLHiA"} 新提分超市退货-通知群
        //{"errcode": 0,"errmsg": "ok","chatid": "wrhInZCgAAV2gNNTpYAAJSSTsLol5VEQ"} 小学-通知群
        //{"errcode": 0,"errmsg": "ok","chatid": "wrhInZCgAAV2gNNTpYAAJSSTsLol5VEQ"} 小学-通知群
        //{"errcode": 0,"errmsg": "ok","chatid": "wrhInZCgAAiLaK5P0pRPOs1JleBvaZCg"} 老师领取通知群
        print_r($response);exit;
    }

    public function chant()
    {
        $app = Factory::work(AssistantModel::config());
        $token = $app->access_token->getToken();//获取企业微信token
        $url = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token={$token['access_token']}";
        $post = [
          'id'=>1,
          'name'=>1,
          'phone'=>1,
          'address'=>1,
          'area'=>1,
          'text'=>1,
          'moban'=>'chinese',
        ];
//        $param = $this->moban($post);
        $param = $this->moban($this->request->post());
        $response = \fast\Http::post($url,$param);
        return json_encode(['msg'=>'success']);
    }
    
    public function moban($post)
    {
        $str = '';
        switch ($post['moban']) {
            case 'teacher':
                $str = '{
                   "chatid": "wrhInZCgAAiLaK5P0pRPOs1JleBvaZCg",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "老师领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font>
                                >手机号：<font color=\"info\">'.$post['phone'].'</font>
                                >学校：<font color=\"info\">'.$post['school'].'</font>
                                >科目：<font color=\"info\">'.$post['subject'].'</font>
                                >版本：<font color=\"info\">'.$post['banben'].'</font>
                                >填写日期：<font color=\"info\">'.$post['createtime'].'</font>"
                }';
                break;
            case 'yuyue':
                 $str = '{
                   "chatid": "14461621356868135921",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "样书预约通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font>
                                >手机号：<font color=\"info\">'.$post['tel'].'</font>
                                >学校：<font color=\"info\">'.$post['school'].'</font>
                                >所在地区：<font color=\"info\">'.$post['area'].$post['address'].'</font>
                                >产品：<font color=\"info\">'.$post['kemu'].'</font>
                                >科目：<font color=\"info\">'.$post['type'].'</font>
                                >版本：<font color=\"info\">'.$post['banben'].'</font>"
                   }
                }';
                break;
             case 'baoming':
                $str = '{
                   "chatid": "14186620304621825010",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "报名表通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font> 
                                >是否开有书店：<font color=\"info\">'.$post['shudian'].'</font> 
                                >所在地区：<font color=\"info\">'.$post['area'].'</font> 
                                >意向代理地区：<font color=\"info\">'.$post['yixiang'].'</font> 
                                >书店/公司名称：<font color=\"info\">'.$post['mingcheng'].'</font> 
                                >联系方式：<font color=\"info\">'.$post['lianxi'].'</font>"
                   }
                }';
                break;
            case 'tmall':
                 $str = '{
                   "chatid": "9607303908516162894",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "新订单通知
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>
                                >商品：<font color=\"info\">'.$post['order_name'].'</font>
                                >会员昵称：<font color=\"info\">'.$post['user_name'].'</font>
                                >实付金额：<font color=\"info\">'.$post['order_amount'].'</font>
                                >支付方式：<font color=\"info\">'.$post['payment'].'</font>
                                >订单来源：<font color=\"info\">'.$post['client'].'</font>"
                   }
                }';
                break;
              case 'tuihuo':
                 $str = '{
                   "chatid": "wrhInZCgAAGv3aPuqHPVh1pzRWYFV--A",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "订单退货通知
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>
                                >商品：<font color=\"info\">'.$post['order_name'].'</font>
                                >会员昵称：<font color=\"info\">'.$post['user_name'].'</font>
                                >收货人：<font color=\"info\">'.$post['consignee'].'</font>
                                >实付金额：<font color=\"info\">'.$post['order_amount'].'</font>
                                >支付方式：<font color=\"info\">'.$post['payment'].'</font>
                                >订单来源：<font color=\"info\">'.$post['client'].'</font>"
                                
                   }
                }';
                break;
              case 'shoptest':
                $str = '{
                   "chatid": "wrhInZCgAAGdxg6PkNtTlzuzQ2EeMmkw",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "新订单通知
                                >订单号：<font color=\"info\">'.$post['order_id'].'</font>
                                >商品：<font color=\"info\">'.$post['store_name'].'</font>
                                >会员昵称：<font color=\"info\">'.$post['user_name'].'</font>
                                >实付金额：<font color=\"info\">'.$post['pay_price'].'</font>
                                >支付方式：<font color=\"info\">'.$post['payment'].'</font>
                                >购买学校：<font color=\"info\">'.$post['school_name'].'</font>
                                >订单来源：<font color=\"info\">'.$post['source'].'</font>"
                   }
                }';
               break;
              case 'shoptest_refund':
                   $str = '{
                   "chatid": "wrhInZCgAA3jsm8OBPP3HOhBhuRTLHiA",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "订单退货通知
                                >订单号：<font color=\"info\">'.$post['order_id'].'</font>
                                >商品：<font color=\"info\">'.$post['store_name'].'</font>
                                >会员昵称：<font color=\"info\">'.$post['user_name'].'</font>
                                >收货人：<font color=\"info\">'.$post['consignee'].'</font>
                                >实付金额：<font color=\"info\">'.$post['pay_price'].'</font>
                                >支付方式：<font color=\"info\">'.$post['payment'].'</font>
                                >购买学校：<font color=\"info\">'.$post['school_name'].'</font>
                                >订单来源：<font color=\"info\">'.$post['source'].'</font>"
                                
                   }
                }';
                break;
              case 'create':
                $str = '{
                   "chatid": "16703006596415092261",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "《考前突破卷·数学》领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >家庭所在地：<font color=\"info\">'.$post['address'].'</font>
                                >领取版本：<font color=\"info\">'.$post['text'].'</font>"
                   }
                }';
                break;
              case 'guess':
                $str = '{
                   "chatid": "16703006596415092261",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "《考前突破卷》领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >家庭所在地：<font color=\"info\">'.$post['address'].'</font>
                                >领取版本：<font color=\"info\">'.$post['text'].'</font>
                                >领取科目：<font color=\"info\">'.$post['subject'].'</font>"
                   }
                }';
                break;
              case 'chinese':
                $str = '{
                   "chatid": "wrhInZCgAA05Ae05n9Eo-o68viQabrsQ",
                   "msgtype":"markdown",
                     "markdown": {
                        "content": "《考前突破卷·语文》领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >家庭所在地：<font color=\"info\">'.$post['address'].'</font>
                                >详细地址：<font color=\"info\">'.$post['text'].'</font>"
                   }
                }';
                break;
              case 'examiation':
                $str = '{
                   "chatid": "wrhInZCgAAoC8lFBSYvvXVjp2Cr1JWXw",
                   "msgtype":"markdown",
                     "markdown": {
                        "content": "《考前猜题卷》领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >地区：<font color=\"info\">'.$post['address'].'</font>
                                >版本：<font color=\"info\">'.$post['type'].'</font>"
                   }
                }';
                break;  
             case 'round':
                 $str = '{
                   "chatid": "wrhInZCgAAmd73Q1zqFF3Fh-mqNGbHLA",
                   "msgtype":"markdown",
                     "markdown": {
                        "content": "高考一轮复习-领取通知，第'.$post['id'].'位
                                >问卷名称：<font color=\"info\">'.$post['volumename'].'</font> 
                                >所选学校：<font color=\"info\">'.$post['schoolname'].'</font> 
                                >所填班级：<font color=\"info\">'.$post['classname'].'</font> 
                                >学生姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >家长姓名：<font color=\"info\">'.$post['parent_name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font>"
                   }
                }';
                break;
             case 'xiaoxue':
                 $str = '{
                   "chatid": "wrhInZCgAAV2gNNTpYAAJSSTsLol5VEQ",
                   "msgtype":"markdown",
                     "markdown": {
                        "content": "小学素材书-领取通知，第'.$post['id'].'位
                                >问卷名称：<font color=\"info\">'.$post['volumename'].'</font> 
                                >所选学校：<font color=\"info\">'.$post['schoolname'].'</font> 
                                >所填班级：<font color=\"info\">'.$post['classname'].'</font> 
                                >学生姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >家长姓名：<font color=\"info\">'.$post['parent_name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >地区：<font color=\"info\">'.$post['address'].'</font>
                                >详细地址：<font color=\"info\">'.$post['text'].'</font>"
                   }
                }';
                break;
              case 'pep':
                $str = '{
                   "chatid": "wrhInZCgAAHwIu_oKVuTuRH0XQDTEchw",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "小学赠品《全知识点普查彩图试卷》纸质版领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >邮寄地址：<font color=\"info\">'.$post['address'].'</font>
                                >在读年级：<font color=\"info\">'.$post['text'].'</font>"
                   }
                }';
                break;
              case 'teachers':
               $str = '{
                   "chatid": "wrhInZCgAAm2NolRU_W4XoV0nhKvBiOg",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "小学教师赠品《小学生绘本课堂·教案》纸质版领取通知，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['phone'].'</font> 
                                >邮寄地址：<font color=\"info\">'.$post['address'].'</font>
                                >所在学校：<font color=\"info\">'.$post['school'].'</font>
                                >学制：<font color=\"info\">'.$post['type'].'</font>
                                >所授年级：<font color=\"info\">'.$post['text'].'</font>"
                   }
                }';
                break;
              case 'recruit':
              $str = '{
                   "chatid": "wrhInZCgAArUogbYnKOf70o-F7tHQaXg",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "招募令，第'.$post['id'].'位
                                >联系人：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font> 
                                >申请城市：<font color=\"info\">'.$post['city'].'</font>
                                >详细地址：<font color=\"info\">'.$post['address'].'</font>
                                >全职或兼职：<font color=\"info\">'.$post['apply_1'].'</font>
                                >城市拥有家长资源：<font color=\"info\">'.$post['apply_2'].'</font>
                                >相关的市场推广经验：<font color=\"info\">'.$post['apply_3'].'</font>
                                >微信：<font color=\"info\">'.$post['weixin'].'</font>
                                >邮箱：<font color=\"info\">'.$post['email'].'</font>
                                >表单来源：<font color=\"info\">'.$post['source'].'</font>
                                >其他希望我们了解的信息：<font color=\"info\">'.$post['info'].'</font>"
                   }
                }';
                break;
              case 'from_check':
                $str = '{
                   "chatid": "17095101238973040856",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "领取，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font>
                                >所在学校：<font color=\"info\">'.$post['school'].'</font>
                                >所在班级：<font color=\"info\">'.$post['class'].'</font>
                                >所在年级：<font color=\"info\">'.$post['grade'].'</font>
                                >所在地区：<font color=\"info\">'.$post['area'].'</font> 
                                >详细地址：<font color=\"info\">'.$post['address'].'</font>"
                   }
                }';
                break;
             case 'from_parent':
               $str = '{
                   "chatid": "16012267003567144092",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "老师领取，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font>
                                >就职学校：<font color=\"info\">'.$post['school'].'</font>
                                >职务：<font color=\"info\">'.$post['zhiwu'].'</font>
                                >所在年级：<font color=\"info\">'.$post['nianji'].'</font>
                                >所在地区：<font color=\"info\">'.$post['intention'].'</font> 
                                >详细地址：<font color=\"info\">'.$post['address'].'</font> 
                                >向全国小学赠书活动：<font color=\"info\">'.$post['zengshu'].'</font>
                                >表单来源：<font color=\"info\">'.$post['source'].'</font>"
                   }
                }';
                break;
              case 'from_family':
                $str = '{
                   "chatid": "16012267003567144092",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "家长看样，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font>
                                >就职学校：<font color=\"info\">'.$post['school'].'</font>
                                >所在年级：<font color=\"info\">'.$post['nianji'].'</font>
                                >所在地区：<font color=\"info\">'.$post['intention'].'</font> 
                                >详细地址：<font color=\"info\">'.$post['address'].'</font>
                                >表单来源：<font color=\"info\">'.$post['source'].'</font>"
                   }
                }';
                break;
            case 'from_lingqu':
                 $str = '{
                   "chatid": "16012267003567144092",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "家长领取，第'.$post['id'].'位
                                >姓名：<font color=\"info\">'.$post['name'].'</font> 
                                >手机号：<font color=\"info\">'.$post['tel'].'</font>
                                >就职学校：<font color=\"info\">'.$post['school'].'</font>
                                >所在年级：<font color=\"info\">'.$post['nianji'].'</font>
                                >所在地区：<font color=\"info\">'.$post['intention'].'</font> 
                                >详细地址：<font color=\"info\">'.$post['address'].'</font>
                                >表单来源：<font color=\"info\">'.$post['source'].'</font>"
                   }
                }';
                break;
             case 'ip':
                 $str = '{
                   "chatid": "11546103548099182395",
                   "msgtype":"text",
                   "text": {
                        "content": "IP地址'.$post['ip'].'"
                   }
                }';
                break;
            case 'ddsh':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有订单审核未通过，需业务人员更新
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>
                                >原因：<font color=\"info\">'.$post['reason'].'</font>"
                   }
                }';
                break;
            case 'ddsh2':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有订单审核通过，财务及物流人员可下载使用
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >创建时间：<font color=\"info\">'.$post['createtime'].'</font>"
                   }
                }';
                break;
            case 'dddr':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有新订单导入，需财务审核
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >创建时间：<font color=\"info\">'.$post['createtime'].'</font>"
                   }
                }';
                break;
            case 'cwdc':
                  $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "财务导出，第'.$post['num'].'次导出
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >开始时间：<font color=\"warning\">'.$post['createtime'].'</font> 
                                >结束时间：<font color=\"warning\">'.$post['endtime'].'</font>
                                >导出人：<font color=\"info\">'.$post['name'].'</font>"
                   }
                }';
                break;
            case 'wldc':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "物流导出，第'.$post['num'].'次导出
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >开始时间：<font color=\"warning\">'.$post['createtime'].'</font> 
                                >结束时间：<font color=\"warning\">'.$post['endtime'].'</font>
                                >导出人：<font color=\"info\">'.$post['name'].'</font>"
                   }
                }';
                break;
            case 'ddxg':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有订单申请作废，需财务审核
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>
                                >作废原因：<font color=\"info\">'.$post['zfreason'].'</font>"
                   }
                }';
                break;
            case 'ddxg2':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有订单修改，需财务审核
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>
                                >修改内容：<font color=\"info\">'.$post['reason'].'</font>"
                   }
                }';
                break;
            case 'ddxg3':
                $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "有订单作废审核通过，请财务人员和物流人员周知
                                >ID：<font color=\"warning\">'.$post['id'].'</font> 
                                >代理商：<font color=\"warning\">'.$post['agent_name'].'</font>
                                >订单号：<font color=\"info\">'.$post['order_sn'].'</font>"
                   }
                }';
                break;
             case 'cwsh':
               $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "财务审核完成，可以下载发货
                                >开始时间：<font color=\"warning\">'.$post['createtime'].'</font> 
                                >结束时间：<font color=\"warning\">'.$post['endtime'].'</font>
                                >审核时间时间：<font color=\"warning\">'.$post['shtime'].'</font>
                                >审核人：<font color=\"info\">'.$post['name'].'</font>"
                   }
                }';
                break;
             case 'wlfh':
               $str = '{
                   "chatid": "wrhInZCgAAURQ5YBWykfd2w1aDQ-xJ4g",
                   "msgtype":"markdown",
                   "markdown": {
                        "content": "物流发货
                                >开始时间：<font color=\"warning\">'.$post['createtime'].'</font> 
                                >结束时间：<font color=\"warning\">'.$post['endtime'].'</font>
                                >发货人：<font color=\"info\">'.$post['name'].'</font>"
                   }
                }';
                break;
             case 'error':
               $str = '{
                   "chatid": "wrhInZCgAAG8n7tVlN7TYnV3vkAkrZmg",
                   "msgtype":"text",
                   "text": {
                        "content": "'.$post['text'].'"
                   }
                }';
                break;
        }
        return $str;
    }

    public function test()
    {
        $data = [
            "chatid"=> "wrhInZCgAAnoBIM8QUn0bRaeoWcqlhRg",
            "msgtype"=>"text",
            "text"=>["content" => "你的快递已到\n请携带工卡前往邮件中心领取"],
            "safe"=>0
        ];
        $this->apps->chat->send($data);
    }

    public function water()
    {
        $messenger = $this->apps->group_robot_messenger;
        //获取当前时间
        $H = date('H',time());
        $W = date("w");
        if($H > 18 || $H < 9 && $W <= 6)
        {
            exit;
        }
        $arr =array(
            1=>'多喝水，不易老，会睡的女人美到老',
            2=>'我们都是小苗儿，快快浇水快快长',
            3=>'自然精华，“饮”领养生',
            4=>'纯净每一天，美丽每一天，健康每一天',
            5=>'多喝水，皮肤嫰出水',
            6=>'喝白开水，做健康人',
            7=>'白开水无味，人生有滋味',
            8=>'满足你的渴望—白开水'
        );
        // 通过构造函数传参
        $text = new Text($arr[rand(1,8)], 'dai');
        // 群组 key
        $groupKey = 'c524707c-15e3-4f56-9f46-e3eb11a5fe3b';
        $messenger->message($text)->toGroup($groupKey)->send();
    }
}
